﻿
function addCookie(pageURL,pageNAME){
	if (document.all){
		   window.external.AddFavorite(pageURL,pageNAME);
	    }
		else if (window.sidebar){
		   window.sidebar.addPanel(pageNAME, pageURL, "");
	}
}

function setHomepage(pageURL){
	if (document.all){
		   document.body.style.behavior='url(#default#homepage)';
		   document.body.setHomePage(pageURL);
	    } else if (window.sidebar) {
		   if (window.netscape) {
			  try {  
				    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
			  } catch (e) {  
		            alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );  
			  }
		   } 
		   var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
		   prefs.setCharPref('browser.startup.homepage',pageURL);
	}
}
//去左空格; 
function ltrim(s){ 
	return s.replace( /^(\s*|　*)/, ""); 
} 
//去右空格; 
function rtrim(s){ 
	return s.replace( /(\s*|　*)$/, ""); 
} 
//去左右空格; 
function trim(s){ 
	return ltrim(rtrim(s));
} 
function dosearch(f){
	if(trim( f.q.value.replace(/[\/_]/g,' ') )==''){
		f.q.value='';	
		alert('关键词不能为空');
		f.q.focus();
		return false;
	}else{
		var sdi = f.searchdomain;
		var sd = "http://www.cscsf.com";
		if(sdi != undefined && sdi.value != ""){
			sd = sdi.value;
		}
		var q = encodeURIComponent(f.q.value.replace(/[\/_]/g,' ')); //'
		
		
		var btype = f.sbts;
		if(f.searchType.value == "bar" && btype != undefined && btype.value != ""){
			q = q+"_sbt_"+btype.value;
		}
		var url= sd+"/search_"+f.searchType.value+"/q_"+q;
		
		if(f.q.style.color.replace(/ /ig,"")=="rgb(198,198,198)" || f.q.style.color=="#c6c6c6" ){ //"
			url+="_source_dfv";
		}
		
		window.location.href=url;
		return false;
	}
}


function addLoadEvent(func) {
    var onLoad = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            onLoad();
            func();
        }
    }
}

function correctPNG() {
    var F = navigator.appVersion.split("MSIE");
    var G = parseFloat(F[1]);
    if ((G >= 5.5) && (document.body.filters)) {
        for (var C = 0; C < document.images.length; C++) {
            var D = document.images[C];
            var I = D.src.toUpperCase();
            if (I.substring(I.length - 3, I.length) == "PNG") {
                var E = (D.id) ? "id='" + D.id + "' " : "";
                var J = (D.className) ? "class='" + D.className + "' " : "";
                var B = (D.title) ? "title='" + D.title + "' " : "title='" + D.alt + "' ";
                var H = "display:inline-block;" + D.style.cssText;
                if (D.align == "left") { H = "float:left;" + H }
                if (D.align == "right") { H = "float:right;" + H }
                if (D.parentElement.href) { H = "cursor:hand;" + H }
                var A = "<span " + E + J + B + " style=\"width:" + D.width + "px; height:" + D.height + "px;" + H + ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + D.src + "', sizingMethod='scale');\"></span>";
                D.outerHTML = A; C = C - 1
            }
        }
    }
}
